USE ASLB
GO
/******************************************************************************
** File: PopulateTables.sql
** Name: PopulateTables
**
** Author:    jocaplan
** Date:      04/22/2009
*******************************************************************************
** Change History
*******************************************************************************
**Date        Author     Desc
**----------  ---------  ------------------------------------------------------
*******************************************************************************/
SET NOCOUNT ON

DECLARE
     @NotificationList varchar(1000) 

RAISERROR('Started the script PopulateTables.sql...',0,1) WITH NOWAIT
RAISERROR('', 0,1) WITH NOWAIT




-- Parameters ************************************************************************************************************

IF NOT EXISTS (SELECT * FROM Parameters WHERE ParamName = 'AnalysisServicesAssembly')
BEGIN
	INSERT INTO Parameters(ParamName, ParamDate, ParamNumber, ParamChar, ParamDescription)
	VALUES('AnalysisServicesAssembly',NULL,NULL,'C:\ASLBSetup\Assembly\Microsoft.AnalysisServices.DLL','Location of Analysis Services Assembly (Microsoft.AnalysisServices.DLL)') 
END
ELSE
BEGIN
   RAISERROR('Seed data already exists for Parameters with ParamName AnalysisServicesAssembly, so not reinserting..',0,1) WITH NOWAIT   
END

IF NOT EXISTS (SELECT * FROM Parameters WHERE ParamName = 'ASLBMonitorAssembly')
BEGIN
	INSERT INTO Parameters(ParamName, ParamDate, ParamNumber, ParamChar, ParamDescription)
	VALUES('ASLBMonitorAssembly',NULL,NULL,'C:\ASLBSetup\Assembly\ASLBMonitor.DLL','Location of ASLBMonitor Assembly (ASLBMonitor.DLL)') 
END
ELSE
BEGIN
   RAISERROR('Seed data already exists for Parameters with ParamName ASLBMonitorAssembly, so not reinserting..',0,1) WITH NOWAIT   
END

IF NOT EXISTS (SELECT * FROM Parameters WHERE ParamName = 'ASLBVersion')
BEGIN
	INSERT INTO Parameters(ParamName, ParamDate, ParamNumber, ParamChar, ParamDescription)
	VALUES('ASLBVersion',NULL,NULL,'1.0','Current version number of ASLB database. Match with version number on assemblies') 
END
ELSE
BEGIN
   RAISERROR('Seed data already exists for Parameters with ParamName ASLBVersion, so not reinserting..',0,1) WITH NOWAIT   
END

IF NOT EXISTS (SELECT * FROM Parameters WHERE ParamName = 'AutoEnable')
BEGIN
	INSERT INTO Parameters(ParamName, ParamDate, ParamNumber, ParamChar, ParamDescription)
	VALUES('AutoEnable',NULL,1,NULL,'Set to true to automatically enable a server after coming back from failure') 
END
ELSE
BEGIN
   RAISERROR('Seed data already exists for Parameters with ParamName AutoEnable, so not reinserting..',0,1) WITH NOWAIT   
END

IF NOT EXISTS (SELECT * FROM Parameters WHERE ParamName = 'FailureNotification')
BEGIN
	INSERT INTO Parameters(ParamName, ParamDate, ParamNumber, ParamChar, ParamDescription)
	VALUES('FailureNotification',NULL,NULL,@NotificationList,'List of users to email in the event of failure') 
END
ELSE
BEGIN
   RAISERROR('Seed data already exists for Parameters with ParamName FailureNotification, so not reinserting..',0,1) WITH NOWAIT   
END

IF NOT EXISTS (SELECT * FROM Parameters WHERE ParamName = 'RoundRobinThreshold')
BEGIN
	INSERT INTO Parameters(ParamName, ParamDate, ParamNumber, ParamChar, ParamDescription)
	VALUES('RoundRobinThreshold',NULL,40,NULL,'Max Value to use Round Robin') 
END
ELSE
BEGIN
   RAISERROR('Seed data already exists for Parameters with ParamName RoundRobinThreshold, so not reinserting..',0,1) WITH NOWAIT   
END

IF NOT EXISTS (SELECT * FROM Parameters WHERE ParamName = 'SessionTimeout')
BEGIN
	INSERT INTO Parameters(ParamName, ParamDate, ParamNumber, ParamChar, ParamDescription)
	VALUES('SessionTimeout',NULL,20,NULL,'Session Timeout in minutes') 
END
ELSE
BEGIN
   RAISERROR('Seed data already exists for Parameters with ParamName SessionTimeout, so not reinserting..',0,1) WITH NOWAIT   
END

IF NOT EXISTS (SELECT * FROM Parameters WHERE ParamName = 'UseRoundRobin')
BEGIN
	INSERT INTO Parameters(ParamName, ParamDate, ParamNumber, ParamChar, ParamDescription)
	VALUES('UseRoundRobin',NULL,0,NULL,'Set to 1 if you wish to used round robin instead of server load') 
END
ELSE
BEGIN
   RAISERROR('Seed data already exists for Parameters with ParamName UseRoundRobin, so not reinserting..',0,1) WITH NOWAIT   
END
